<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  assignment = grading_box
  submission ||= nil
%>
<% if assignment.grading_type == "points" %>
  <input
    type="text" size="3"
    value="<%= I18n.n(submission.entered_score) if submission %>"
    class="grading_value grading_box" id="student_grading_<%= assignment.id %>"
    style="<%= hidden unless submission %> text-align: center;"/>
<% elsif assignment.grading_type == "percent" %>
  <span class="grading_box" id="student_grading_<%= assignment.id %>" style="<%= hidden unless submission %>">
    <input
      type="text" size="3" class="grading_value" style="text-align: center;"
      value="<%= I18n.n(submission.entered_grade.to_f, percentage: true) if submission %>"
    />
    <span style="display: none;">%</span>
  </span>
<% elsif assignment.grading_type == "letter_grade" %>
  <input
    type="text" size="3" class="grading_value grading_box score_value"
    value="<%= I18n.n(submission.entered_score) if submission %>"
    id="student_grading_<%= assignment.id %>"
    style="<%= hidden unless submission %> text-align: center;"
  />
<% elsif assignment.grading_type == "gpa_scale" %>
  <input
    type="text" size="3" class="grading_value grading_box score_value gpa_scale_cell"
    value="<%= I18n.n(submission.entered_score) if submission %>"
    id="student_grading_<%= assignment.id %>"
    style="<%= hidden unless submission %> text-align: center;"/>
<% elsif assignment.grading_type == "pass_fail"
     complete_selected = submission && %w[pass complete].include?(submission.grade)
     incomplete_selected = submission && %w[fail incomplete].include?(submission.grade)
%>
  <select
    class="grading_value grading_box pass_fail"
    id="student_grading_<%= assignment.id %>"
    style="<%= hidden unless submission %> text-align: left;"
  >
    <option value="" style="padding-left: 5px;">---</option>
    <option value="complete" style="padding-left: 5px;" <%= "selected" if complete_selected %>>
      {{#t}}Complete{{/t}}
    </option>
    <option value="incomplete" style="padding-left: 5px;" <%= "selected" if incomplete_selected %>>
      {{#t}}Incomplete{{/t}}
    </option>
  </select>
<% end %>
